var param = $.cookie("group_id")
group_type = $.cookie("group_type")
$('.group_name').text(group_type + '群体信息')
var data = {type: "get_group", group_id: param}
$.post("http://127.0.0.1:9998/analysis/get_group/" + data.group_id, data, (group) => {
    console.log(group)
    var myChart2f = echarts.init(document.getElementById('main_yq2'));
    is_sensitive = group.data.idInfo.isSensitiveNum
    is_not_sensitive = group.data.idInfo.isNotSensitiveNum
    // 敏感用户饼状图
    option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: ['敏感用户', '非敏感用户']
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: '35%',
                center: ['50%', '50%'],
                data: [
                    {value: is_sensitive, name: '敏感用户'},
                    {value: is_not_sensitive, name: '非敏感用户'},
                ],
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    myChart2f.setOption(option);
    window.onresize = function () {         //自适应屏幕
        myChart2f.resize()
    }
    //地域比例饼图
    var myChart5f = echarts.init(document.getElementById('main_DiYu'));
    // <*V2.0*>
    var city_info = group.data.cityInfo
    if(city_info != null){

        //左侧标签 遍历点
        DiMing_key = Object.keys(city_info)      // 要 所有 keys
        //new
        var ZuoCeBiaoQian = []
        for (var i in DiMing_key) {
            ZuoCeBiaoQian.push(DiMing_key[i])
        }
        //图 遍历点
        var Tu = []
        for (var i in DiMing_key) {
            var obj = {}
            obj['name'] = DiMing_key[i]
            obj['value'] = city_info[DiMing_key[i]]
            Tu.push(obj)    //这进去就是键值对儿？
        }

    }

    option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: ZuoCeBiaoQian,
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: '35%',
                center: ['50%', '50%'],
                data: Tu,
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    myChart5f.setOption(option);
    window.onresize = function () {         //自适应屏幕
        myChart5f.resize()
    }
    //工作比例柱状图
    // 基于准备好的dom，初始化echarts实例
    var myChartf = echarts.init(document.getElementById('main_yx'));
    // <*V1.0*>
    var zy_q = group.data.userLabelInfo
    console.log(zy_q)

    //要名称
    zy_key = Object.keys(zy_q)
    // console.log(zy_key);
    var zy_key_name = []
    for (var i in zy_key) {
        zy_key_name.push(Object.keys(zy_q)[i])
    }
    //要数据
    var zy_value_num = []
    for (var i in zy_key) {
        zy_value_num.push(zy_q[Object.keys(zy_q)[i]])
    }

    // 指定图表的配置项和数据
    var option = {
        color: ['#00688B'],
        title: {
            text: '万（单位）'
        },
        tooltip: {},
        legend: {
            data: ['人口']
        },
        xAxis: {
            data: zy_key,

        },
        yAxis: {},
        series: [{

            name: '人口',
            type: 'bar',
            data: zy_value_num,
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChartf.setOption(option);
    window.onresize = function () {         //自适应屏幕
        myChartf.resize()
    }
}, 'json');
